<template>
  <div class="not-found-container">
    <div class="not-found-content">
      <h1 class="error-code">404</h1>
      <p class="error-message">哎呀，页面飞走了~</p>
      <router-link to="/" class="back-home">返回首页</router-link>
    </div>
    <div class="floating-items">
      <div class="floating-item leaf"></div>
      <div class="floating-item cloud1"></div>
      <div class="floating-item cloud2"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';

const router = useRouter();

function goHome() {
  router.push('/');
}
</script>

<style scoped>
.not-found-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f5f5f5;
  font-family: 'Arial', sans-serif;
  overflow: hidden;
  position: relative;
}

.not-found-content {
  text-align: center;
  position: relative;
  z-index: 2;
}

.error-code {
  font-size: 6em;
  color: #333;
  margin-bottom: 0.25em;
}

.error-message {
  font-size: 1.5em;
  color: #666;
  margin-bottom: 1em;
}

.back-home {
  display: inline-block;
  padding: 0.75em 1.5em;
  font-size: 1em;
  color: #fff;
  background-color: #007bff;
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}

.back-home:hover {
  background-color: #0056b3;
}

.floating-items {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
}

.floating-item {
  position: absolute;
  bottom: -100%;
  animation: float 10s infinite linear;
}

.leaf {
  width: 30px;
  height: 30px;
  background-image: url('leaf.png'); /* 确保您有一个名为 leaf.png 的图片在 public 文件夹中 */
  background-size: cover;
  left: 50%;
  animation-delay: 2s;
}

.cloud1 {
  width: 50px;
  height: 50px;
  background-image: url('cloud1.png'); /* 确保您有一个名为 cloud1.png 的图片在 public 文件夹中 */
  background-size: cover;
  left: 20%;
  animation-delay: 4s;
}

.cloud2 {
  width: 70px;
  height: 70px;
  background-image: url('cloud2.png'); /* 确保您有一个名为 cloud2.png 的图片在 public 文件夹中 */
  background-size: cover;
  left: 80%;
  animation-delay: 6s;
}

@keyframes float {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-300%);
  }
}
</style>
